#include "Retangulo.h"

using namespace std;

Rectangulo::Rectangulo(Materiais *mat, Texturas *tex, float x1, float y1, float x2, float y2) : Primitiva(mat, tex) {

	this->x1 = x1;
	this->y1 = y1;
	this->x2 = x2;
	this->y2 = y2;
}

void Rectangulo::aplica() {
	glPushMatrix();
	cout << "------------++++++++ Aplica Rectangulo +++++++++-----------------" << endl;
	this->getMaterial()->aplica();
	cout << "------------++++++++ Aplica RectanguloMaterial +++++++++-----------------" << endl;
	this->getTextura()->aplica();
	cout << "------------++++++++ Aplica RectangulTextura+++++++++-----------------" << endl;
	cout << this->x1 << " " << this->y1 << " " << this->x2 << " " << this->y2 << endl;
	cout << this->getTextura()->getFicheiro() << endl;
	glEnable(GL_NORMALIZE);
	glBegin(GL_POLYGON);
		glNormal3d(0.0,0.0,1.0);
		glTexCoord2f(0.0,0.0); glVertex3f(this->x1,this->y1,0.0);
		glTexCoord2f(1.0,0.0); glVertex3f(this->x2,this->y1,0.0);
		glTexCoord2f(1.0,1.0); glVertex3f(this->x2,this->y2,0.0);
		glTexCoord2f(0.0,1.0); glVertex3f(this->x1,this->y2,0.0);
	glEnd();
	glDisable(GL_NORMALIZE);
	cout << "------------++++++++ Aplica RectanguloDesenha+++++++++-----------------" << endl;
	glPopMatrix();
}